package com.luxshare.aos.demo;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.luxshare.aos.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SimpleAdapterActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        List<Map<String, String>> dataList = new ArrayList<>();

        Map<String, String> datas = new HashMap<>();
        datas.put("姓名", "张三");
        datas.put("性别", "男");
        dataList.add(datas);

        datas = new HashMap<>();
        datas.put("姓名", "李四");
        datas.put("性别", "女");
        dataList.add(datas);

        ListView listView = new ListView(this);
        listView.setAdapter(new SimpleAdapter(this, dataList, R.layout.activity_simpleadapter, new String[]{"姓名", "性别"}, new int[]{R.id.listviewitem_name, R.id.listviewitem_grade}));

        setContentView(listView);
    }

}
